﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kira.Compiler.Bods
{
    /// <summary>
    /// Marked a Class that is a BODS element
    /// priority is ByAttributeValue > ByAttribute > ByElement = Default
    /// if ByElement & Default both exist, will throw an exception
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    internal class XmlElementMappingAttribute : Attribute
    {
        internal String ElementName { get; private set; }
        internal String AttributeName { get; private set; }
        internal String AttributeValue { get; private set; }

        internal XmlElementMappingType MappingType
        {
            get;
            private set;
        }
        internal XmlElementMappingAttribute()
        {
            MappingType = XmlElementMappingType.Default;
        }

        internal XmlElementMappingAttribute(String elementName)
        {
            this.ElementName = elementName;
            MappingType = XmlElementMappingType.ByElement;
        }

        internal XmlElementMappingAttribute(String elementName, String attrName)
            : this(elementName)
        {
            this.AttributeName = attrName;
            MappingType = XmlElementMappingType.ByAttribute;
        }

        internal XmlElementMappingAttribute(String elementName, String attrName, String attrValue)
            : this(elementName, attrName)
        {
            this.AttributeValue = attrValue;
            MappingType = XmlElementMappingType.ByAttributeValue;
        }
    }

    internal enum XmlElementMappingType
    {
        Default, ByElement, ByAttribute, ByAttributeValue
    }
}
